package Demo_Old.Demo.streamtype;

import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

public class BaiduTest {

    public static void main(String[] args) {

        try(InputStreamReader inputStreamReader=new InputStreamReader(new URL("https://www.baidu.com").openStream(),"utf-8");
            BufferedReader bufferedReader=new BufferedReader(inputStreamReader);
            FileWriter fileWriter=new FileWriter("src/baidu.txt");) {

            String read=null;
            while((read=bufferedReader.readLine())!=null){
                fileWriter.write(read);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
